home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Network / PowerScript 14 / PowerScript < prev    next >
Encoding:
Text File  |  1999-03-04  |  18.2 KB  |  706 lines  |  [TEXT/ToyS]

  1. -- User setable properties
  2. property kasOpenWindowWhenRun : true -- Set to false to not open the remote item's window in the Finder when run
  3. property kasAllowAlerts : true -- Set to false to stop any alerts from appearing
  4. property kasServerAlerts : true -- Set to false to stop warnings about missed servers
  5. property kasFinder : "Finder" -- name of application to open RemoteLaunchers
  6. property kasAppendage : " ->" -- Appended to file name if we can't use original
  7. property kasPrefixLauncher : "≈ " -- Prefix named of launchers with these characters.
  8.  
  9. -- Internal/User setable globals
  10. property gasLinkSet : false -- Has the friend been asked for? - set to true to never ask
  11. property gasLinkNeed : false
  12. property kasLinkUserDft : "CasaVision" -- Defaults for linking access
  13. property kasLinkPassDft : ""
  14.  
  15. property gasServSet : false
  16. property gasServNeed : false
  17. property kasServUserDft : "Synapse" -- Defaults for server access
  18. property kasServPassDft : ""
  19. property kasServNTDft : ""
  20.  
  21. -- Internal globals
  22. global gasLinkUser -- Our friend on all machines
  23. global gasLinkPass -- Our friend's password on all machines
  24. global gasServUser -- Our friend on all machines
  25. global gasServPass -- Our friend's password on all machines
  26. global gasServNT -- Volume password
  27. global gasStat -- Status window
  28.  
  29. property gasOurAlias : "" -- The alias we own
  30. property gasOurStatus : "" -- Empty, "RemoteLauncher" or "RemoteFolder"
  31. property gasOurServer : "" -- Set to server of gasOurAlias
  32. property gasOurZone : "" -- Set to zone of gasOurAlias
  33. property gasOurName : "" -- Name of original alias
  34. property gasOurVol : "" -- Name of volume alias resides on
  35. property gasOurType : "" -- If we are a RemoteLauncher, this is our file type
  36. property gasCopyLoc : {-1, -1} -- The location of the copy window
  37. property gasStatLoc : {-1, -1} -- The location of the status window
  38. property kasStatName : "PowerScript V1.4"
  39.  
  40.  
  41. on run
  42.     if (gasOurStatus is "") then
  43.         ShowInitAlert()
  44.     else if (gasOurStatus is "RemoteLauncher") then
  45.         RunRemoteLauncher()
  46.     else if (gasOurStatus is "RemoteFolder") then
  47.         RunRemoteFolder(kasOpenWindowWhenRun)
  48.     else
  49.         beep
  50.     end if
  51. end run
  52.  
  53.  
  54. on open fsObjs
  55.     if option key down of (input state) then
  56.         if the number of items in fsObjs is not 1 then
  57.             ShowInitAlert()
  58.         else if (ShowChoice("You have the option key pressed." & return & return & "Do you wish to reinitialize this script with the object you dropped on it?")) then
  59.             SetScriptAlias(item 1 of fsObjs)
  60.         end if
  61.     else if (gasOurStatus is "") then
  62.         if the number of items in fsObjs is not 1 then
  63.             ShowInitAlert()
  64.         else
  65.             SetScriptAlias(item 1 of fsObjs)
  66.         end if
  67.     else if (gasOurStatus is "RemoteLauncher") then
  68.         (*
  69.         What we want to do here if the file dropped on us is on
  70.         the same server as our alias:
  71.         If we are a document and an application is dropped on us,
  72.         we open us with that application. If we are an application
  73.         and a document is dropped on us we open that document with
  74.         this application.
  75.         *)
  76.         -- Get the user/password
  77.         GetFriend(false)
  78.         
  79.         set cantOpen to false
  80.         set iAmApp to (gasOurType is "APPL")
  81.         
  82.         repeat with fsObj in fsObjs
  83.             set aInfo to alias info from fsObj
  84.             
  85.             if the alias server of aInfo is not gasOurServer then
  86.                 set cantOpen to true
  87.             else
  88.                 set fInfo to basic info for fsObj
  89.                 set isAnApp to (system type of fInfo is "APPL")
  90.                 
  91.                 if (iAmApp is isAnApp) then
  92.                     set cantOpen to true
  93.                 else
  94.                     if (iAmApp) then
  95.                         set appAli to gasOurAlias
  96.                         set docAli to fsObj
  97.                     else
  98.                         set appAli to fsObj
  99.                         set docAli to gasOurAlias
  100.                     end if
  101.                     
  102.                     if (not RemoteLaunchUsing(appAli, docAli)) then return
  103.                 end if
  104.             end if
  105.         end repeat
  106.         
  107.         if (cantOpen) then ShowOpenAlert()
  108.         
  109.     else if (gasOurStatus is "RemoteFolder") then
  110.         
  111.         set wasMounted to IsVolMounted(gasOurVol)
  112.         
  113.         if (RunRemoteFolder(false)) then
  114.             set replaceAll to false
  115.             
  116.             repeat with fsObj in fsObjs
  117.                 try
  118.                     set gasCopyLoc to ¬
  119.                         (AkuaCopy fsObj located at gasCopyLoc with resuming given «class Dest»:gasOurAlias)
  120.                 on error err
  121.                     if (err contains "Duplicate") then
  122.                         set replaceOne to replaceAll
  123.                         set fsName to original name of (alias info from fsObj)
  124.                         if (not replaceOne) then
  125.                             set replaceChoice to ¬
  126.                                 ShowChoices("A file named “" & fsName & "” already exists." & return & ¬
  127.                                     return & "Do you wish to replace it?", {"Skip", "Replace", "Replace All"})
  128.                             
  129.                             set replaceAll to replaceChoice is "Replace All"
  130.                             set replaceOne to replaceAll or (replaceChoice is "Replace")
  131.                         end if
  132.                         
  133.                         if (replaceOne) then
  134.                             try
  135.                                 collate ((gasOurAlias as string) & fsName) as alias with the trasher -- Move it to Trash
  136.                                 set gasCopyLoc to ¬
  137.                                     (AkuaCopy fsObj located at gasCopyLoc with resuming given «class Dest»:gasOurAlias)
  138.                             on error err
  139.                                 ShowCopyAlert(fsObj, err)
  140.                             end try
  141.                         end if
  142.                     else
  143.                         ShowCopyAlert(fsObj, err)
  144.                     end if
  145.                 end try
  146.             end repeat
  147.             if (not wasMounted) then ¬
  148.                 PutAwayVol(gasOurVol)
  149.         end if
  150.     end if
  151. end open
  152.  
  153.  
  154. on quit
  155.     if ((the open windows) contains "Status") then ¬
  156.         set gasStatLoc to screen location of ¬
  157.             (display info gasStat with disposal)
  158.     continue quit
  159. end quit
  160.  
  161.  
  162. on RunRemoteFolder(openInFinder)
  163.     set mounted to true
  164.     
  165.     -- Get the user/password
  166.     GetFriend(false)
  167.     
  168.     -- Mount the remote volume?
  169.     if (gasOurServer is not "") then -- Local?        
  170.         ShowAction("Connecting to server")
  171.         try
  172.             mount server volume gasOurVol ¬
  173.                 with volume password gasServNT on server gasOurServer ¬
  174.                 in AppleTalk zone gasOurZone ¬
  175.                 as user name gasServUser ¬
  176.                 with password gasServPass ¬
  177.                 
  178.         on error
  179.             ShowAction("Checking with remote Finder")
  180.             if (CouldBeSharing(gasOurZone, gasOurServer)) then
  181.                 try
  182.                     mount server volume gasOurVol ¬
  183.                         with volume password gasServNT on server gasOurServer ¬
  184.                         in AppleTalk zone gasOurZone ¬
  185.                         as user name gasServUser ¬
  186.                         with password gasServPass ¬
  187.                         
  188.                 on error errStr number errNum
  189.                     ShowAction("Couldn't mount it.")
  190.                     ShowError(errStr, errNum)
  191.                     if (kasServerAlerts) then
  192.                         ShowMountAlert()
  193.                     else
  194.                         beep
  195.                     end if
  196.                     set mounted to false
  197.                 end try
  198.             else
  199.                 ShowStatus("Remote sharing could not be started.")
  200.                 if (kasServerAlerts) then
  201.                     ShowMountAlert()
  202.                 else
  203.                     beep
  204.                 end if
  205.                 set mounted to false
  206.             end if
  207.         end try
  208.     end if
  209.     
  210.     if (mounted) then
  211.         ShowAction("Finding folder")
  212.         try
  213.             set gfiDestFolder to ¬
  214.                 resolve chain gasOurAlias ¬
  215.                     with volume password gasServNT ¬
  216.                     as user name gasServUser ¬
  217.                     with password gasServPass
  218.             
  219.             -- Tell Finder to open the alias now that it is mounted
  220.             ShowAction("Opening folder")
  221.             if (openInFinder) then
  222.                 tell application kasFinder
  223.                     open gasOurAlias
  224.                     activate
  225.                 end tell
  226.             end if
  227.         on error errStr number errNum
  228.             ShowError(errStr, errNum)
  229.             
  230.             set mounted to false
  231.             
  232.             if (kasServerAlerts) then
  233.                 ShowAliasAlert()
  234.             else
  235.                 beep
  236.             end if
  237.         end try
  238.     end if
  239.     
  240.     return mounted
  241. end RunRemoteFolder
  242.  
  243.  
  244. on RunRemoteLauncher()
  245.     -- Get the user/password
  246.     GetFriend(false)
  247.     
  248.     if (gasOurServer is not "") then -- Remote?        
  249.         talk as user gasLinkUser ¬
  250.             with password gasLinkPass ¬
  251.             on server gasOurServer ¬
  252.             in AppleTalk zone gasOurZone
  253.     end if
  254.     
  255.     if (gasOurServer is "") then
  256.         set suspect to application kasFinder
  257.     else
  258.         talk as user gasLinkUser ¬
  259.             with password gasLinkPass ¬
  260.             on server gasOurServer ¬
  261.             in AppleTalk zone gasOurZone
  262.         
  263.         set suspect to application kasFinder ¬
  264.             of machine gasOurServer ¬
  265.             of zone gasOurZone
  266.     end if
  267.     
  268.     try
  269.         -- Don't wait for a response, assume the aliases are correct
  270.         tell suspect to open gasOurAlias
  271.     on error errStr number errNum
  272.         ShowError(errStr, errNum)
  273.         ShowConnectAlert(kasFinder, errNum)
  274.     end try
  275. end RunRemoteLauncher
  276.  
  277.  
  278. on RemoteLaunchUsing(appAli, docAli)
  279.     set aName to original name of (alias info from appAli)
  280.     
  281.     -- Is the app running?
  282.     if (gasOurServer is "") then
  283.         -- Don't wait for a response, assume the aliases are correct
  284.         tell application kasFinder ¬
  285.             to open docAli given «class usin»:appAli
  286.     else
  287.         talk as user gasLinkUser ¬
  288.             with password gasLinkPass ¬
  289.             on server gasOurServer ¬
  290.             in AppleTalk zone gasOurZone
  291.         
  292.         if (the server processes aName on server gasOurServer in AppleTalk zone gasOurZone ¬
  293.             as user name gasLinkUser with password gasLinkPass) is not "" then
  294.             try
  295.                 tell application aName of machine gasOurServer ¬
  296.                     of zone gasOurZone to open docAli
  297.             on error err
  298.                 ShowConnectAlert(aName, err)
  299.             end try
  300.         else
  301.             try
  302.                 -- Don't wait for a response, assume the aliases are correct
  303.                 tell application kasFinder of machine gasOurServer ¬
  304.                     of zone gasOurZone to open docAli given «class usin»:appAli
  305.             on error err
  306.                 ShowConnectAlert(kasFinder, err)
  307.                 return false
  308.             end try
  309.         end if
  310.     end if
  311.     
  312.     return true
  313. end RemoteLaunchUsing
  314.  
  315.  
  316. on ChooseScriptAlias()
  317.     if ShowChoices("Do you wish to activate this script with a folder/volume or a file?", {"Folder", "File"}) is "File" then
  318.         set myObj to ¬
  319.             choose file with prompt "Choose a server file for this PowerScript RA"
  320.     else
  321.         set myObj to ¬
  322.             choose folder with prompt "Choose a server folder or volume for this PowerScript RA"
  323.     end if
  324.     
  325.     SetScriptAlias(myObj)
  326. end ChooseScriptAlias
  327.  
  328.  
  329. on SetScriptAlias(aliasObj)
  330.     -- My Path
  331.     set myPath to (path to me)
  332.     
  333.     -- Grab an alias
  334.     set gasOurAlias to aliasObj
  335.     set aInfo to alias info from gasOurAlias
  336.     set fInfo to basic info for gasOurAlias
  337.     
  338.     -- Save the info we need
  339.     set gasOurServer to alias server of aInfo
  340.     set gasOurZone to alias zone of aInfo
  341.     set gasOurVol to alias volume of aInfo
  342.     set gasOurName to original name of aInfo
  343.     set gasOurType to system type of fInfo
  344.     
  345.     set newName to gasOurName -- Start with name of original item
  346.     
  347.     -- What will we be - a mounter or a launcher?
  348.     if (catalog kind of fInfo) is a folder then
  349.         set gasOurStatus to "RemoteFolder"
  350.         set gasServNeed to true
  351.     else
  352.         set gasOurStatus to "RemoteLauncher"
  353.         set gasLinkNeed to true
  354.         set newName to kasPrefixLauncher & newName
  355.     end if
  356.     
  357.     -- Try to set our name to dropped name
  358.     try
  359.         collate myPath renaming it to newName
  360.     on error
  361.         -- If we can't use the original name, try an appendage :)
  362.         try
  363.             collate myPath renaming it to newName & kasAppendage
  364.         on error
  365.             beep
  366.         end try
  367.     end try
  368.     
  369.     -- Get the user/password
  370.     GetFriend(false)
  371.     
  372.     -- Set our icon to dropped icon
  373.     set the icon of myPath to (the icon for gasOurAlias) with compatibility
  374.     
  375.     try
  376.         tell application "Finder" to update myPath -- Double dose?
  377.     on error
  378.         beep
  379.     end try
  380. end SetScriptAlias
  381.  
  382.  
  383. on GetFriend(override) -- Should later use some modifier key to override?!?
  384.     set gasLinkUser to kasLinkUserDft
  385.     set gasLinkPass to kasLinkPassDft
  386.     set gasServUser to kasServUserDft
  387.     set gasServPass to kasServPassDft
  388.     set gasServNT to kasServNTDft
  389.     
  390.     if (gasOurServer is "") then -- Local?
  391.         set gasLinkSet to true
  392.         set gasServSet to true
  393.     else
  394.         -- Get linking (and server) user?
  395.         if (gasLinkNeed) then GetOneFriend(true, override)
  396.         
  397.         -- Get server user?
  398.         if (gasServNeed) then GetOneFriend(false, override)
  399.     end if
  400. end GetFriend
  401.  
  402.  
  403. on GetOneFriend(isLink, override)
  404.     if (isLink) then
  405.         set userMode to "linking"
  406.         if (gasLinkSet) then
  407.             set defUser to gasLinkUser
  408.             set defPass to gasLinkPass
  409.         else
  410.             set defUser to kasLinkUserDft
  411.             set defPass to kasLinkPassDft
  412.         end if
  413.         set defNT to kasServNTDft -- Not used
  414.         set passButtons to {"Cancel", "OK"}
  415.         set passButton to 2
  416.     else
  417.         set userMode to "sharing"
  418.         if (gasServSet) then
  419.             set defUser to gasServUser
  420.             set defPass to gasServPass
  421.             set defNT to gasServNT
  422.         else
  423.             set defUser to kasServUserDft
  424.             set defPass to kasServPassDft
  425.             set defNT to kasServNTDft
  426.         end if
  427.         set passButtons to {"Cancel", "NT Password…", "OK"}
  428.         set passButton to 3
  429.     end if
  430.     
  431.     set usrPwd to KeyChainLookUp(gasOurZone, gasOurServer, isLink)
  432.     
  433.     if (override or usrPwd is {}) then
  434.         set chosen to display dialog ¬
  435.             "Enter the friendly " & userMode & ¬
  436.             " user's name for the server \"" & gasOurServer ¬
  437.             & "\"…" default answer defUser ¬
  438.             default button 2 with icon note
  439.         
  440.         if (the button returned of chosen is "OK") then
  441.             set defUser to the text returned of chosen
  442.         else
  443.             return
  444.         end if
  445.         
  446.         set chosen to display dialog ¬
  447.             "Enter the friendly " & userMode & ¬
  448.             " user's password…" buttons passButtons ¬
  449.             default answer defPass default button passButton with icon note
  450.         
  451.         if (the button returned of chosen is not "Cancel") then
  452.             set defPass to the text returned of chosen
  453.         else
  454.             return
  455.         end if
  456.         
  457.         if (the button returned of chosen is "NT Password…") then
  458.             set chosen to display dialog ¬
  459.                 "Enter the volume password for Windoze NT…" default answer ¬
  460.                 defNT default button 2 with icon note
  461.             
  462.             if (the button returned of chosen is not "Cancel") then
  463.                 set gasServNT to the text returned of chosen
  464.             else
  465.                 return
  466.             end if
  467.         end if
  468.         
  469.         -- Save encrypted user/pass for future access
  470.         KeyChainSave(gasOurZone, gasOurServer, isLink, defUser, defPass, defNT)
  471.     else
  472.         set defUser to item 1 of usrPwd
  473.         set defPass to item 2 of usrPwd
  474.         set defNT to item 3 of usrPwd
  475.     end if
  476.     
  477.     if (isLink) then
  478.         set gasLinkSet to true
  479.         set gasLinkUser to defUser
  480.         set gasLinkPass to defPass
  481.     else
  482.         set gasServSet to true
  483.         set gasServUser to defUser
  484.         set gasServPass to defPass
  485.         set gasServNT to defNT
  486.     end if
  487. end GetOneFriend
  488.  
  489.  
  490. on PutAwayVol(volName)
  491.     -- Volume
  492.     try
  493.         set vAlias to (vol alias of (the volume info of volume named volName))
  494.         eject vAlias
  495.     on error
  496.         beep
  497.     end try
  498. end PutAwayVol
  499.  
  500.  
  501. on IsVolMounted(volName)
  502.     -- Volume
  503.     try
  504.         set x to the volume info of volume named volName
  505.         return true
  506.     on error
  507.         return false
  508.     end try
  509. end IsVolMounted
  510.  
  511.  
  512. on CouldBeSharing(servZone, servName)
  513.     GetOneFriend(true, false) -- Get linking user
  514.     
  515.     talk as user gasLinkUser ¬
  516.         with password gasLinkPass ¬
  517.         on server servName ¬
  518.         in AppleTalk zone servZone
  519.     
  520.     try
  521.         set isOn to («class fshr» ¬
  522.             of application kasFinder ¬
  523.             of machine servName ¬
  524.             of zone servZone)
  525.         
  526.         if (not isOn) then
  527.             set «class fshr» of application kasFinder ¬
  528.                 of machine servName ¬
  529.                 of zone servZone to true
  530.             
  531.             ShowAction("Wait for Sharing")
  532.             set waitSecs to 333
  533.             
  534.             repeat while not («class fshr» of application kasFinder ¬
  535.                 of machine servName ¬
  536.                 of zone servZone)
  537.                 ShowStatus("Wait another " & waitSecs & " seconds.")
  538.                 pause for 120
  539.                 set waitSecs to waitSecs - 2
  540.                 if (waitSecs < 1) then exit repeat
  541.             end repeat
  542.             
  543.             if («class fshr» of application kasFinder ¬
  544.                 of machine servName ¬
  545.                 of zone servZone) then
  546.                 ShowStatus("It is up!")
  547.             else
  548.                 ShowStatus("Can't get it up!")
  549.                 beep
  550.             end if
  551.             
  552.             return («class fshr» of application ¬
  553.                 kasFinder of machine servName of zone servZone)
  554.         end if
  555.     on error errStr
  556.         if (errStr contains "-911") then
  557.             GetOneFriend(true, true)
  558.             return CouldBeSharing()
  559.         end if
  560.     end try
  561.     
  562.     return false
  563. end CouldBeSharing
  564.  
  565.  
  566. on ShowAliasAlert()
  567.     if ShowChoices("Couldn't resolve alias for " & gasOurName & ¬
  568.         " on " & gasOurVol & " from machine " & gasOurServer & ¬
  569.         "." & return & return & "Would you like to reset it?", ¬
  570.         {"Refind item", "No"}) is not "No" then ¬
  571.         ChooseScriptAlias()
  572. end ShowAliasAlert
  573.  
  574.  
  575. on ShowMountAlert()
  576.     ShowServerAlert("Couldn't mount volume " & gasOurVol & ¬
  577.         " from " & gasOurServer ¬
  578.         & " in zone " & gasOurZone)
  579. end ShowMountAlert
  580.  
  581.  
  582. on ShowConnectAlert(appName, err)
  583.     if (not kasServerAlerts) then
  584.         beep
  585.     else
  586.         ShowServerAlert("Couldn't connect to " & appName & " on " & ¬
  587.             gasOurServer & " in zone " & gasOurZone & return & return & "Error: " & err)
  588.     end if
  589. end ShowConnectAlert
  590.  
  591.  
  592. on ShowServerAlert(msg)
  593.     if ShowChoices(msg, {"Reenter Password", "OK"}) ¬
  594.         is not "OK" then ¬
  595.         GetFriend(true)
  596. end ShowServerAlert
  597.  
  598.  
  599. on ShowInitAlert()
  600.     if ShowChoices("This script must first be activated by dropping exactly one item on it." & ¬
  601.         return & return & "Please see the information file that accompanied it.", ¬
  602.         {"Activate", "OK"}) is not "OK" then ¬
  603.         ChooseScriptAlias()
  604. end ShowInitAlert
  605.  
  606.  
  607. on ShowOpenAlert()
  608.     ShowAlert("This script is currently in Launcher mode and can thus not process any files dropped on it." & ¬
  609.         return & return & "To reconfigure the script, open it with ScriptEditor and save it.")
  610. end ShowOpenAlert
  611.  
  612.  
  613. on ShowCopyAlert(fsObj, err)
  614.     ShowAlert("An error (" & (err as string) & ") occured copying “" & ¬
  615.         (original name of (alias info from fsObj)) & "”." & return & return & ¬
  616.         "The network may have been interrupted or a disk error may have occured")
  617. end ShowCopyAlert
  618.  
  619.  
  620. on ShowAlert(msgStr)
  621.     if (kasAllowAlerts) then
  622.         display dialog msgStr buttons {"Damn!"} ¬
  623.             default button 1 with icon caution
  624.     else
  625.         beep
  626.     end if
  627. end ShowAlert
  628.  
  629.  
  630. on ShowChoice(msgStr)
  631.     return (ShowChoices(msgStr, {"No", "Yes"}) is "Yes")
  632. end ShowChoice
  633.  
  634.  
  635. on ShowChoices(msgStr, choices)
  636.     set choice to ¬
  637.         display dialog msgStr buttons choices ¬
  638.             default button (number of items of choices) ¬
  639.             with icon stop
  640.     return (button returned of choice)
  641. end ShowChoices
  642.  
  643.  
  644. on StatusNew()
  645.     if ((the open windows) contains kasStatName) then
  646.         return display info titled kasStatName
  647.     else
  648.         set gasStat to display info titled kasStatName
  649.     end if
  650. end StatusNew
  651.  
  652.  
  653. on ShowAction(msg)
  654.     StatusNew()
  655.     display info gasStat message msg at line 1 ¬
  656.         using bg color (20 * 1024 + 20 * 32 + 31)
  657. end ShowAction
  658.  
  659.  
  660. on ShowStatus(msg)
  661.     StatusNew()
  662.     display info gasStat message msg at line 2 ¬
  663.         using bg color (20 * 1024 + 31 * 32 + 20)
  664. end ShowStatus
  665.  
  666.  
  667. on ShowError(errMsg, errNum)
  668.     StatusNew()
  669.     display info gasStat message (errMsg & " (" & errNum & ")") at line 3 ¬
  670.         using bg color (31 * 1024 + 20 * 32 + 20)
  671.     pause for 120
  672. end ShowError
  673.  
  674.  
  675. property kasKeyChainPassword : "PowerScript" -- Encrypt stored data with this
  676. property kasPrefsFileName : "PowerScript Prefs" -- File name in <Preferences>
  677.  
  678. on KeyChainLookUp(zoneName, serverName, isLinking)
  679.     set prefType to "πSRV"
  680.     if (isLinking) then set prefType to "πLNK"
  681.     
  682.     try
  683.         set myKeyData to load preference of type prefType ¬
  684.             named (zoneName & ":" & serverName) ¬
  685.             in file named kasPrefsFileName
  686.     on error
  687.         return {}
  688.     end try
  689.     
  690.     return (encrypt the data myKeyData ¬
  691.         with password kasKeyChainPassword)
  692. end KeyChainLookUp
  693.  
  694.  
  695. on KeyChainSave(zoneName, serverName, isLinking, usr, pwd, ntPwd)
  696.     set myKey to encrypt the data {usr, pwd, ntPwd} ¬
  697.         with password kasKeyChainPassword
  698.     
  699.     set prefType to "πSRV"
  700.     if (isLinking) then set prefType to "πLNK"
  701.     
  702.     save preference myKey of type prefType ¬
  703.         named (zoneName & ":" & serverName) ¬
  704.         in file named kasPrefsFileName
  705. end KeyChainSave
  706.